package com.spring.handler;

import com.spring.util.ServiceUtil;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 * @ClassName MyHandler
 * @Description TODO
 * @Author ZhaoKai
 * @Date 2022-02-1616:06
 * @Version 1.0
 **/
public class MyInvocationHandler implements InvocationHandler {
    Object target;

    public MyInvocationHandler(Object target) {
        this.target = target;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        ServiceUtil.doBefore();
        Object res = method.invoke(target, args);
        ServiceUtil.doAfter();
        return res;
    }
}
